﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace XNA.Common.Objects
{
	public abstract class Entity : GameObject
	{
		#region CONSTRUCTION

		public Entity (float x, float y, float z, int height = 0, float rotation = 0, ModelData model = null)
		{
			Position = new Vector3 (x, y, z);
			Height = height;
			Rotation = Matrix.CreateRotationY (rotation);
			ModelData = model;
		}
		
		#endregion

		#region PROPERTIES

		public Vector3 Position
		{
			get;
			set;
		}

		public Matrix Rotation
		{
			get;
			set;
		}

		public float Height
		{
			get;
			set;
		}

		public ModelData ModelData
		{
			get;
			set;
		}

		#endregion

		#region METHODS (PUBLIC)

		public override void Draw (GameTime time)
		{
			if (ModelData != null)
			{
				PaintBrush.Brush.DrawModel (
							ModelData.SetUp * GetPositionMatrix (),
							Technique.Textured,
							ModelData);
			}

			base.Draw (time);
		}

		public Matrix GetPositionMatrix ()
		{
			return Rotation * Matrix.CreateTranslation (Position.X, Position.Y, Position.Z);
		}

		#endregion
	}
}
